import asyncio
import time

from pyppeteer import launch


async def main():
    browser = await launch({"headless": False}, args=['--disable-infobars'])
    page = await browser.newPage()
    await page.setViewport({'width': 500, 'height': 500})
    await page.goto('https://demo.mycodes.net/daima/suopingjiesuo/')

    await page.mouse.move(250, 250)
    await page.mouse.down()  # 按下鼠标
    a, b = 150, 250
    for i in range(5):  # 向右
        a += 34
        await page.mouse.move(a, b)  # 移动鼠标
        time.sleep(0.2)
    for i in range(5):  # 向下
        b += 34
        await page.mouse.move(a, b)  # 移动鼠标
        time.sleep(0.2)
    for i in range(5):  # 向左
        a -= 34
        await page.mouse.move(a, b)  # 移动鼠标
        time.sleep(0.2)
    for i in range(2):  # 向上
        b -= 34
        await page.mouse.move(a, b)  # 移动鼠标
        time.sleep(0.2)
    for i in range(3):  # 向右
        a += 35
        await page.mouse.move(a, b)  # 移动鼠标
    await page.mouse.up()
    time.sleep(10)


asyncio.get_event_loop().run_until_complete(main())
